mirror of https://github.com/sgoudham/carbon.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.0 KiB
JavaScript
42 lines
1.0 KiB
JavaScript
/* eslint-env mocha */
|
|
/* global cy */
|
|
import {editorVisible} from '../support'
|
|
|
|
// usually we can visit the page before each test
|
|
// but these tests use the url, which means wasted page load
|
|
// so instead visit the desired url in each test
|
|
|
|
describe('localStorage', () => {
|
|
const themeDropdown = () =>
|
|
cy.get('#toolbar .dropdown-container').first()
|
|
|
|
const pickTheme = (name = 'Blackboard') =>
|
|
themeDropdown()
|
|
.click()
|
|
.contains(name)
|
|
.click()
|
|
|
|
it('is empty initially', () => {
|
|
cy.visit('/')
|
|
editorVisible()
|
|
cy.window().its('localStorage')
|
|
.should('have.length', 0)
|
|
})
|
|
|
|
it('saves on theme change', () => {
|
|
cy.visit('/')
|
|
editorVisible()
|
|
pickTheme('Blackboard')
|
|
themeDropdown().contains('Blackboard')
|
|
|
|
cy.window().its('localStorage.CARBON_STATE')
|
|
.then(JSON.parse)
|
|
.its('theme').should('equal', 'blackboard')
|
|
|
|
// visiting page again restores theme from localStorage
|
|
cy.visit('/')
|
|
themeDropdown().contains('Blackboard')
|
|
cy.url().should('contain', 't=blackboard')
|
|
})
|
|
})
|