Skip to content

Commit

Permalink
test: Add tests for new util functions
Browse files Browse the repository at this point in the history
- add tests for rgbDecimalToHex
- add tests for decimalToHex
  • Loading branch information
TheGreatRefrigerator committed Apr 28, 2023
1 parent 749c686 commit ec2e775
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/support/__tests__/utils.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Utils from '../utils'

describe('Utils rgbDecimalToHex', () => {
it('should return normal hex colors', (done) => {
let res_black = Utils.rgbDecimalToHex(0,0,0)
expect(res_black).to.equal('#000000')
let res_white = Utils.rgbDecimalToHex(255,255,255)
expect(res_white).to.equal('#ffffff')
done()
})
})

describe('Utils decimalToHex', () => {
it('should convert decimals to 2 digit hex values', (done) => {
expect( Utils.decimalToHex(15)).to.equal('0f')
expect( Utils.decimalToHex(0)).to.equal('00')
expect( Utils.decimalToHex(16)).to.equal('10')
expect( Utils.decimalToHex(255)).to.equal('ff')
done()
})
})

0 comments on commit ec2e775

Please sign in to comment.