-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add expected behavior tests and comments
- Loading branch information
1 parent
e49afd9
commit e93b007
Showing
5 changed files
with
64 additions
and
17 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
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 |
---|---|---|
|
@@ -42,5 +42,6 @@ | |
"security": ["nosec_sc"] | ||
}] | ||
} | ||
} | ||
}, | ||
"typoCount": 0 | ||
} |
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
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,43 @@ | ||
const fs = require("fs") | ||
const path = require("path") | ||
const { checkTypos } = require("../index") | ||
const tdValidator = require("../index").tdValidator | ||
|
||
const rootDir = path.join("./", "examples", "tds") | ||
|
||
const dirPath = path.join(rootDir, "typo") | ||
const fileNames = fs.readdirSync(dirPath) | ||
const refResult = { | ||
report: { | ||
json: 'passed', | ||
schema: 'passed', | ||
defaults: expect.stringMatching(/warning|passed/), | ||
jsonld: 'passed', | ||
additional: expect.stringMatching(/warning|passed/) | ||
}, | ||
details: { | ||
enumConst: expect.stringMatching(/failed|warning|passed/), | ||
propItems: expect.stringMatching(/failed|warning|passed/), | ||
security: expect.stringMatching(/failed|warning|passed/), | ||
propUniqueness: expect.stringMatching(/failed|warning|passed/), | ||
multiLangConsistency: expect.stringMatching(/failed|warning|passed/), | ||
linksRelTypeCount: expect.stringMatching(/failed|warning|passed/), | ||
readWriteOnly: expect.stringMatching(/failed|warning|passed/), | ||
uriVariableSecurity: expect.stringMatching(/failed|warning|passed/) | ||
}, | ||
detailComments: expect.any(Object) | ||
} | ||
fileNames.forEach( fileName => { | ||
test(fileName, done => { | ||
fs.readFile(path.join(dirPath, fileName), "utf-8", (err, tdToTest) => { | ||
if (err) {done(err)} | ||
tdValidator(tdToTest, ()=>{},{}).then( result => { | ||
expect(result).toEqual(refResult) | ||
const tdJson = JSON.parse(tdToTest) | ||
const typoCount = tdJson['typoCount'] | ||
expect(checkTypos(tdToTest).length).toEqual(typoCount) | ||
done() | ||
}, errTwo => {done(errTwo)}) | ||
}) | ||
}) | ||
}) |
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