-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #121 from conveyal/dev
v3.4.0
- Loading branch information
Showing
11 changed files
with
445 additions
and
24 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
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,103 @@ | ||
exports[`import { analysis, project as proj } from '../utils/messages' 1`] = ` | ||
Array [ | ||
undefined, | ||
Array [ | ||
Array [ | ||
"analysis", | ||
"analysis", | ||
], | ||
Array [ | ||
"project", | ||
"proj", | ||
], | ||
], | ||
] | ||
`; | ||
|
||
exports[`import { analysis, project as proj }, messages from '../utils/messages' 1`] = ` | ||
Array [ | ||
"messages", | ||
Array [ | ||
Array [ | ||
"analysis", | ||
"analysis", | ||
], | ||
Array [ | ||
"project", | ||
"proj", | ||
], | ||
], | ||
] | ||
`; | ||
|
||
exports[`import {analysis, project as proj} from '../utils/messages' 1`] = ` | ||
Array [ | ||
undefined, | ||
Array [ | ||
Array [ | ||
"analysis", | ||
"analysis", | ||
], | ||
Array [ | ||
"project", | ||
"proj", | ||
], | ||
], | ||
] | ||
`; | ||
|
||
exports[`import messages, { analysis, project as proj } from '../utils/messages' 1`] = ` | ||
Array [ | ||
"messages", | ||
Array [ | ||
Array [ | ||
"analysis", | ||
"analysis", | ||
], | ||
Array [ | ||
"project", | ||
"proj", | ||
], | ||
], | ||
] | ||
`; | ||
|
||
exports[`import msgs from '../utils/messages' 1`] = ` | ||
Array [ | ||
"msgs", | ||
Array [], | ||
] | ||
`; | ||
|
||
exports[`lint-messages should lint file 1`] = ` | ||
Array [ | ||
Array [ | ||
"common.downloadRegional", | ||
6, | ||
], | ||
Array [ | ||
"analysis.stop", | ||
8, | ||
], | ||
Array [ | ||
"analysis.stop", | ||
9, | ||
], | ||
Array [ | ||
"project.delete", | ||
12, | ||
], | ||
Array [ | ||
"project.delete", | ||
13, | ||
], | ||
Array [ | ||
"common.runRegional", | ||
14, | ||
], | ||
Array [ | ||
"common.stopRegional", | ||
14, | ||
], | ||
] | ||
`; |
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,60 @@ | ||
/* globals describe, expect, it */ | ||
|
||
const testFile = ` | ||
import messages, { analysis, project as proj } from '../utils/messages' | ||
import Component, { React, PropTypes } from 'react' | ||
const test = messages.common.download | ||
const test2 = messages.common.downloadRegional | ||
const test3 = <div>{analysis.run}</div> | ||
const test3b = <div>{analysis.stop}</div> | ||
const test4 = analysis.stop | ||
const test5 = proj.new | ||
// handle multiple messages in one line | ||
const test6 = test5 ? proj.delete : proj.new | ||
const test7 = test6 ? proj.new : proj.delete | ||
const test8 = test7 ? messages.common.runRegional : messages.common.stopRegional | ||
` | ||
|
||
// test messages, some of the referenced messages are undefined | ||
const testMessages = { | ||
common: { | ||
download: 'Download' | ||
}, | ||
analysis: { | ||
run: 'Run' | ||
}, | ||
project: { | ||
new: 'New' | ||
} | ||
} | ||
|
||
describe('lint-messages', () => { | ||
const { lintFileContents, parseImportLine } = require('../../lib/lint-messages') | ||
it('should parse root import correctly', () => { | ||
expect(parseImportLine("import msgs from '../utils/messages'")) | ||
.toMatchSnapshot("import msgs from '../utils/messages'") | ||
}) | ||
|
||
it('should parse named imports correctly', () => { | ||
expect(parseImportLine("import { analysis, project as proj } from '../utils/messages'")) | ||
.toMatchSnapshot("import { analysis, project as proj } from '../utils/messages'") | ||
|
||
// make sure it works when spacing is smaller | ||
expect(parseImportLine("import {analysis, project as proj} from '../utils/messages'")) | ||
.toMatchSnapshot("import {analysis, project as proj} from '../utils/messages'") | ||
}) | ||
|
||
it('should parse named and default imports together correctly', () => { | ||
expect(parseImportLine("import messages, { analysis, project as proj } from '../utils/messages'")) | ||
.toMatchSnapshot("import messages, { analysis, project as proj } from '../utils/messages'") | ||
|
||
// try it with the default import after the named imports | ||
expect(parseImportLine("import { analysis, project as proj }, messages from '../utils/messages'")) | ||
.toMatchSnapshot("import { analysis, project as proj }, messages from '../utils/messages'") | ||
}) | ||
|
||
it('should lint file', () => { | ||
expect(lintFileContents(testMessages, testFile)).toMatchSnapshot() | ||
}) | ||
}) |
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
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
Oops, something went wrong.