forked from amzn/style-dictionary
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main'
- Loading branch information
Showing
26 changed files
with
380 additions
and
153 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,2 @@ | ||
# See https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners | ||
* @amzn/style-dictionary |
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
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
103 changes: 103 additions & 0 deletions
103
__tests__/common/formatHelpers/createPropertyFormatter.test.js
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 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
import createPropertyFormatter from '../../../src/common/formatHelpers/createPropertyFormatter' | ||
import createDictionary from '../../../src/utils/createDictionary' | ||
|
||
const dictionary = createDictionary({ | ||
properties: { | ||
tokens: { | ||
foo: { | ||
original: { | ||
value: '5px', | ||
type: 'spacing', | ||
}, | ||
attributes: { | ||
category: 'tokens', | ||
type: 'foo', | ||
}, | ||
name: 'tokens-foo', | ||
path: ['tokens', 'foo'], | ||
value: '5px', | ||
type: 'spacing', | ||
}, | ||
bar: { | ||
original: { | ||
value: '{tokens.foo}', | ||
type: 'spacing', | ||
}, | ||
attributes: { | ||
category: 'tokens', | ||
type: 'bar', | ||
}, | ||
name: 'tokens-bar', | ||
path: ['tokens', 'bar'], | ||
value: '5px', | ||
type: 'spacing', | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
const transformedDictionary = createDictionary({ | ||
properties: { | ||
tokens: { | ||
foo: { | ||
original: { | ||
value: '5px', | ||
type: 'spacing', | ||
}, | ||
attributes: { | ||
category: 'tokens', | ||
type: 'foo', | ||
}, | ||
name: 'tokens-foo', | ||
path: ['tokens', 'foo'], | ||
value: '5px', | ||
type: 'spacing', | ||
}, | ||
bar: { | ||
original: { | ||
value: '{tokens.foo}', | ||
type: 'spacing', | ||
}, | ||
attributes: { | ||
category: 'tokens', | ||
type: 'bar', | ||
}, | ||
name: 'tokens-bar', | ||
path: ['tokens', 'bar'], | ||
value: 'changed by transitive transform', | ||
type: 'spacing', | ||
}, | ||
}, | ||
}, | ||
}) | ||
|
||
describe('common', () => { | ||
describe('formatHelpers', () => { | ||
describe('createPropertyFormatter', () => { | ||
it('should support outputReferences', () => { | ||
const propFormatter = createPropertyFormatter({ outputReferences: true, dictionary, format: 'css' }) | ||
expect(propFormatter(dictionary.tokens.tokens.foo)).toEqual(' --tokens-foo: 5px;') | ||
expect(propFormatter(dictionary.tokens.tokens.bar)).toEqual(' --tokens-bar: var(--tokens-foo);') | ||
}) | ||
|
||
it('should support outputReferences when values are transformed by (transitive) "value" transforms', () => { | ||
const propFormatter = createPropertyFormatter({ outputReferences: true, dictionary, format: 'css' }) | ||
expect(propFormatter(transformedDictionary.tokens.tokens.foo)).toEqual(' --tokens-foo: 5px;') | ||
expect(propFormatter(transformedDictionary.tokens.tokens.bar)).toEqual(' --tokens-bar: var(--tokens-foo);') | ||
}) | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.