Skip to content

Commit 482b1c4

Browse files
author
Peter Marton
committed
test(transform/service): cover with tests
1 parent bc0d1f1 commit 482b1c4

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

src/transform/pod.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ describe('Transform Pod', () => {
190190
})
191191
})
192192

193-
describe('meta and status', () => {
194-
it('should cleanup meta and status', () => {
193+
describe('meta', () => {
194+
it('should cleanup meta', () => {
195195
const { chart } = podTransform({}, podChart)
196196

197197
expect(chart.metadata.creationTimestamp).to.be.equal(undefined)

src/transform/service.spec.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
'use strict'
2+
3+
const { expect } = require('chai')
4+
const serviceTransform = require('./service')
5+
6+
describe('Transform Service', () => {
7+
let serviceChart
8+
9+
beforeEach(() => {
10+
serviceChart = {
11+
name: 'my-service',
12+
metadata: {
13+
creationTimestamp: 1234,
14+
selfLink: '/self/service'
15+
},
16+
spec: {
17+
type: 'LoadBalancer',
18+
clusterIP: '1.2.3.4'
19+
},
20+
status: ''
21+
}
22+
})
23+
24+
describe('spec.data transform', () => {
25+
it('should extract data', () => {
26+
const { values, chart } = serviceTransform({}, serviceChart)
27+
28+
expect(values).to.be.eql({
29+
type: 'LoadBalancer'
30+
})
31+
32+
expect(chart.spec.type).to.be.equal('{{ .Values.type | default "LoadBalancer" }}')
33+
})
34+
35+
it('should respect scope', () => {
36+
const { chart } = serviceTransform({}, serviceChart, 'myService')
37+
38+
expect(chart.spec.type).to.be.equal('{{ .Values.myService.type | default "LoadBalancer" }}')
39+
})
40+
})
41+
42+
describe('meta, status', () => {
43+
it('should cleanup meta, clusterIP and status', () => {
44+
const { chart } = serviceTransform({}, serviceChart)
45+
46+
expect(chart.metadata.selfLink).to.be.equal(undefined)
47+
expect(chart.metadata.creationTimestamp).to.be.equal(undefined)
48+
expect(chart.spec.clusterIP).to.be.equal(undefined)
49+
expect(chart.status).to.be.equal(undefined)
50+
})
51+
})
52+
})

0 commit comments

Comments
 (0)