-
-
Notifications
You must be signed in to change notification settings - Fork 391
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding VS Code tests in typescript. Run test changing launch mode to …
…"Launch Test". Remove javascript files.
- Loading branch information
1 parent
c1f03c2
commit 2b0a3b9
Showing
5 changed files
with
103 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
describe("PragmaUtil", () => { | ||
require("./pragmaUtil"); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import * as testRunner from "vscode/lib/testrunner"; | ||
|
||
testRunner.configure({ | ||
ui: "bdd", | ||
useColors: true, | ||
timeout: 5000 | ||
}); | ||
module.exports = testRunner; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { expect } from "chai"; | ||
import fs = require("fs"); | ||
import { OsType } from "../../src/enums"; | ||
import PragmaUtil from "../../src/pragmaUtil"; | ||
|
||
let testSettings = null; | ||
|
||
describe("Process before upload", function() { | ||
this.beforeAll(() => { | ||
testSettings = fs.readFileSync( | ||
__dirname + "/../../../test/pragmaUtil/testSettings.json", | ||
"utf8" | ||
); | ||
}); | ||
|
||
it("should remove @sync-ignore and @sync ignore lines", () => { | ||
expect(PragmaUtil.removeIgnoreBlocks(testSettings)) | ||
.to.not.contains("@sync-ignore") | ||
.and.not.contains("@sync ignore"); | ||
}); | ||
|
||
it("should trim os, host and env", () => { | ||
expect(PragmaUtil.processBeforeUpload(testSettings)).to.match( | ||
/@sync os=linux host=trim env=TEST_ENV/ | ||
); | ||
}); | ||
|
||
it("should comment line after linebreak", () => { | ||
const line = '// @sync host=mac1 os=_mac_\n\t"mac": 3,'; | ||
expect(PragmaUtil.commentLineAfterBreak(line)).to.match(/\/\/\s*"mac"/); | ||
}); | ||
|
||
it("should uncomment line after linebreak", () => { | ||
const line = '// @sync host=mac1 os=_mac_\n\t//"mac": 3,'; | ||
expect(PragmaUtil.uncommentLineAfterBreak(line)).to.match(/\s*"mac"/); | ||
}); | ||
|
||
it("should get eight @sync pragma valid lines", () => { | ||
const processed = PragmaUtil.processBeforeUpload(testSettings); | ||
expect(PragmaUtil.matchPragmaSettings(processed).length).to.be.equals(8); | ||
}); | ||
|
||
it("should uncomment all lines", () => { | ||
const commentedSettings = ` | ||
// @sync os=linux | ||
// "window": 1, | ||
// @sync os=mac | ||
// "mac": 1 | ||
`; | ||
|
||
expect(PragmaUtil.processBeforeUpload(commentedSettings)) | ||
.to.match(/\s+"window"/) | ||
.and.to.match(/\s+"mac"/); | ||
}); | ||
|
||
it("should uncomment lines before write file for os=linux", () => { | ||
const commentedSettings = `{ | ||
// @sync os=linux | ||
// "linux": 1, | ||
// @sync os=mac | ||
"mac": 1 | ||
}`; | ||
const processed = PragmaUtil.processBeforeWrite( | ||
commentedSettings, | ||
OsType.Linux, | ||
null | ||
); | ||
expect(processed) | ||
.to.match(/\s+"linux"/) | ||
.and.to.match(/.+\/\/"mac"/); | ||
}); | ||
|
||
it("should not comment os=linux settings lines", () => { | ||
let processed = PragmaUtil.processBeforeUpload(testSettings); | ||
processed = PragmaUtil.processBeforeWrite(processed, OsType.Linux, null); | ||
expect(processed).to.match(/\s+"not_commented"/); | ||
}); | ||
|
||
it("should leave only settings that matches with os=mac host=mac2 env=TEST_ENV", () => { | ||
const processed = PragmaUtil.processBeforeUpload(testSettings); | ||
// tslint:disable-next-line:no-string-literal | ||
process.env["TEST_ENV"] = "1"; | ||
expect(PragmaUtil.processBeforeWrite(processed, OsType.Mac, "mac2")) | ||
.to.match(/\n\s+"mac2"/) | ||
.and.match(/\n\s+"mactest"/); | ||
}); | ||
|
||
it("should remove all comments and parse JSON", () => { | ||
const possibleJson = PragmaUtil.removeAllComments(testSettings); | ||
expect(JSON.parse.bind(null, possibleJson)).to.not.throw(); | ||
}); | ||
}); |