|
| 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