-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Tag): update to 2.0 styles (#2087)
- use new render color tokens - update layout - update tests and snapshots
- Loading branch information
1 parent
497d4a9
commit a344222
Showing
8 changed files
with
312 additions
and
452 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 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
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,54 @@ | ||
import { generateSnapshots } from '@chanzuckerberg/story-utils'; | ||
import { render } from '@testing-library/react'; | ||
import React from 'react'; | ||
|
||
import { Tag } from './Tag'; | ||
import * as stories from './Tag.stories'; | ||
import type { StoryFile } from '../../util/utility-types'; | ||
|
||
describe('<Tag />', () => { | ||
beforeEach(() => { | ||
// Add in mocks for the calls that can occur in implementation to suppress logging in tests | ||
const consoleMock = jest.spyOn(console, 'error'); | ||
const consoleWarnMock = jest.spyOn(console, 'warn'); | ||
consoleMock.mockImplementation(); | ||
consoleWarnMock.mockImplementation(); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.resetAllMocks(); | ||
}); | ||
|
||
generateSnapshots(stories as StoryFile); | ||
|
||
describe('emits messages when misused', () => { | ||
let consoleErrorMock: jest.SpyInstance, consoleWarnMock: jest.SpyInstance; | ||
beforeEach(() => { | ||
consoleWarnMock = jest.spyOn(console, 'warn'); | ||
consoleErrorMock = jest.spyOn(console, 'error'); | ||
consoleWarnMock.mockImplementation(); | ||
consoleErrorMock.mockImplementation(); | ||
}); | ||
|
||
it('errors when specifying hasOutline', () => { | ||
render(<Tag hasOutline label="click" />); | ||
|
||
expect(consoleWarnMock).toHaveBeenCalledTimes(0); | ||
expect(consoleErrorMock).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it('warns when variant is used', () => { | ||
render(<Tag label="click" variant="brand" />); | ||
|
||
expect(consoleWarnMock).toHaveBeenCalledTimes(1); | ||
expect(consoleErrorMock).toHaveBeenCalledTimes(0); | ||
}); | ||
|
||
it('warns when text is used', () => { | ||
render(<Tag text="click" />); | ||
|
||
expect(consoleWarnMock).toHaveBeenCalledTimes(1); | ||
expect(consoleErrorMock).toHaveBeenCalledTimes(0); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.