-
Notifications
You must be signed in to change notification settings - Fork 567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jest testing #133
Jest testing #133
Changes from 23 commits
ccce11f
6ca983c
b8ca175
a6ea89e
0d76f8a
145d51b
04df754
14693b0
cca0487
149982a
1682ec0
a3ecf3e
82ab444
cc4eea0
c73d1d8
e42201f
5b86080
990f913
5b60aba
a0f4cd3
2845396
9aaaa34
20ddb54
598142c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"asset": { | ||
"font": { | ||
"icon": { | ||
"value": "./test/__assets/fonts/scapp_icons-regular.ttf" | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"asset": { | ||
"image": { | ||
"flag": { | ||
"us": { | ||
"mdpi": { | ||
"value": "__tests__/__assets/images/mdpi/flag_us_base.png" | ||
}, | ||
"hdpi": { | ||
"value": "__tests__/__assets/images/hdpi/flag_us_base.png" | ||
}, | ||
"xhdpi": { | ||
"value": "__tests__/__assets/images/xhdpi/flag_us_base.png" | ||
}, | ||
"xxhdpi": { | ||
"value": "__tests__/__assets/images/xxhdpi/flag_us_base.png" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with | ||
* the License. A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions | ||
* and limitations under the License. | ||
*/ | ||
|
||
var helpers = require('./__helpers'); | ||
var StyleDictionary = require('../index'); | ||
|
||
describe('buildAllPlatforms', () => { | ||
|
||
beforeEach(() => { | ||
helpers.clearOutput(); | ||
}); | ||
|
||
afterEach(() => { | ||
helpers.clearOutput(); | ||
}); | ||
|
||
it('should work with json config', () => { | ||
var StyleDictionaryExtended = StyleDictionary.extend(__dirname + '/__configs/test.json'); | ||
StyleDictionaryExtended.buildAllPlatforms(); | ||
expect(helpers.fileExists('./__tests__/__output/web/_icons.css')).toBeTruthy(); | ||
expect(helpers.fileExists('./__tests__/__output/android/colors.xml')).toBeTruthy(); | ||
}); | ||
|
||
it('should work with js config', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test isn't doing what it is intending to I don't think. We should be extending style dictionary with a js config file, like in the current test file: https://github.com/amzn/style-dictionary/blob/master/test/buildAllPlatforms.js There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, you're right. I didn't notice it was doing two different tests, one for a JSON and one for a JS config file. I have fixed it in an upcoming commit, please check if it's ok now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good to me There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good to me! |
||
var StyleDictionaryExtended = StyleDictionary.extend(__dirname + '/__configs/test.js'); | ||
StyleDictionaryExtended.buildAllPlatforms(); | ||
expect(helpers.fileExists('./__tests__/__output/web/_icons.css')).toBeTruthy(); | ||
expect(helpers.fileExists('./__tests__/__output/android/colors.xml')).toBeTruthy(); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with | ||
* the License. A copy of the License is located at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions | ||
* and limitations under the License. | ||
*/ | ||
|
||
var buildFile = require('../lib/buildFile'); | ||
var helpers = require('./__helpers'); | ||
|
||
function format() { | ||
return "hi"; | ||
} | ||
|
||
describe('buildFile', () => { | ||
|
||
beforeEach(() => { | ||
helpers.clearOutput(); | ||
}); | ||
|
||
afterEach(() => { | ||
helpers.clearOutput(); | ||
}); | ||
|
||
it('should error if format doesnt exist or isnt a function', () => { | ||
expect( | ||
buildFile.bind(null, '__tests__/__output/test.txt', {}, {}, {}) | ||
).toThrow('Please enter a valid file format'); | ||
expect( | ||
buildFile.bind(null, '__tests__/__output/test.txt', [], {}, {}) | ||
).toThrow('Please enter a valid file format'); | ||
expect( | ||
buildFile.bind(null, '__tests__/__output/test.txt', null, {}, {}) | ||
).toThrow('Please enter a valid file format'); | ||
}); | ||
|
||
it('should error if destination doesnt exist or isnt a string', () => { | ||
expect( | ||
buildFile.bind(null, {}, format, {}, {}) | ||
).toThrow('Please enter a valid destination'); | ||
expect( | ||
buildFile.bind(null, [], format, {}, {}) | ||
).toThrow('Please enter a valid destination'); | ||
expect( | ||
buildFile.bind(null, null, format, {}, {}) | ||
).toThrow('Please enter a valid destination'); | ||
}); | ||
|
||
it('should write to a file properly', () => { | ||
buildFile('test.txt', format, {buildPath: '__tests__/__output/'}, {}); | ||
expect(helpers.fileExists('./__tests__/__output/test.txt')).toBeTruthy(); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be "./tests/__assets/fonts/scapp_icons-regular.ttf" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mmm. not sure exactly what that prop refers to. I can't find tests that use it or that TTF file. do you remember something about this test?