Skip to content

Commit

Permalink
test the colors too
Browse files Browse the repository at this point in the history
  • Loading branch information
chris48s committed Feb 13, 2018
1 parent 21903e0 commit fdd6af4
Show file tree
Hide file tree
Showing 3 changed files with 185 additions and 0 deletions.
78 changes: 78 additions & 0 deletions service-tests/chocolatey.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ const {
isMetric,
isVPlusDottedVersionNClauses
} = require('./helpers/validators');
const colorscheme = require('../lib/colorscheme.json');
const {
versionJsonWithDash,
versionJsonFirstCharZero,
versionJsonFirstCharNotZero
} = require('./helpers/nuget-fixtures.js');

const t = new ServiceTester({ id: 'chocolatey', title: 'Chocolatey' });
module.exports = t;
Expand Down Expand Up @@ -47,6 +53,42 @@ t.create('version (valid)')
value: isVPlusDottedVersionNClauses,
}));

t.create('version (mocked, yellow badge)')
.get('/v/scriptcs.json?style=_shields_test')
.intercept(nock => nock('https://www.chocolatey.org')
.get("/api/v2/Packages()?$filter=Id%20eq%20%27scriptcs%27%20and%20IsLatestVersion%20eq%20true")
.reply(200, versionJsonWithDash)
)
.expectJSON({
name: 'chocolatey',
value: 'v1.2-beta',
colorB: colorscheme.yellow.colorB
});

t.create('version (mocked, orange badge)')
.get('/v/scriptcs.json?style=_shields_test')
.intercept(nock => nock('https://www.chocolatey.org')
.get("/api/v2/Packages()?$filter=Id%20eq%20%27scriptcs%27%20and%20IsLatestVersion%20eq%20true")
.reply(200, versionJsonFirstCharZero)
)
.expectJSON({
name: 'chocolatey',
value: 'v0.35',
colorB: colorscheme.orange.colorB
});

t.create('version (mocked, blue badge)')
.get('/v/scriptcs.json?style=_shields_test')
.intercept(nock => nock('https://www.chocolatey.org')
.get("/api/v2/Packages()?$filter=Id%20eq%20%27scriptcs%27%20and%20IsLatestVersion%20eq%20true")
.reply(200, versionJsonFirstCharNotZero)
)
.expectJSON({
name: 'chocolatey',
value: 'v1.2.7',
colorB: colorscheme.blue.colorB
});

t.create('version (not found)')
.get('/v/not-a-real-package.json')
.expectJSON({name: 'chocolatey', value: 'not found'});
Expand Down Expand Up @@ -74,6 +116,42 @@ t.create('version (pre) (valid)')
value: isVPlusDottedVersionNClauses,
}));

t.create('version (pre) (mocked, yellow badge)')
.get('/vpre/scriptcs.json?style=_shields_test')
.intercept(nock => nock('https://www.chocolatey.org')
.get("/api/v2/Packages()?$filter=Id%20eq%20%27scriptcs%27%20and%20IsAbsoluteLatestVersion%20eq%20true")
.reply(200, versionJsonWithDash)
)
.expectJSON({
name: 'chocolatey',
value: 'v1.2-beta',
colorB: colorscheme.yellow.colorB
});

t.create('version (pre) (mocked, orange badge)')
.get('/vpre/scriptcs.json?style=_shields_test')
.intercept(nock => nock('https://www.chocolatey.org')
.get("/api/v2/Packages()?$filter=Id%20eq%20%27scriptcs%27%20and%20IsAbsoluteLatestVersion%20eq%20true")
.reply(200, versionJsonFirstCharZero)
)
.expectJSON({
name: 'chocolatey',
value: 'v0.35',
colorB: colorscheme.orange.colorB
});

t.create('version (pre) (mocked, blue badge)')
.get('/vpre/scriptcs.json?style=_shields_test')
.intercept(nock => nock('https://www.chocolatey.org')
.get("/api/v2/Packages()?$filter=Id%20eq%20%27scriptcs%27%20and%20IsAbsoluteLatestVersion%20eq%20true")
.reply(200, versionJsonFirstCharNotZero)
)
.expectJSON({
name: 'chocolatey',
value: 'v1.2.7',
colorB: colorscheme.blue.colorB
});

t.create('version (pre) (not found)')
.get('/vpre/not-a-real-package.json')
.expectJSON({name: 'chocolatey', value: 'not found'});
Expand Down
29 changes: 29 additions & 0 deletions service-tests/helpers/nuget-fixtures.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use strict';

const versionJsonWithDash = JSON.stringify({
d: {
results: [
{ NormalizedVersion: '1.2-beta' }
]
}
});
const versionJsonFirstCharZero = JSON.stringify({
d: {
results: [
{ NormalizedVersion: '0.35' }
]
}
});
const versionJsonFirstCharNotZero = JSON.stringify({
d: {
results: [
{ NormalizedVersion: '1.2.7' }
]
}
});

module.exports = {
versionJsonWithDash,
versionJsonFirstCharZero,
versionJsonFirstCharNotZero
};
78 changes: 78 additions & 0 deletions service-tests/powershellgallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ const {
isMetric,
isVPlusDottedVersionNClauses
} = require('./helpers/validators');
const colorscheme = require('../lib/colorscheme.json');
const {
versionJsonWithDash,
versionJsonFirstCharZero,
versionJsonFirstCharNotZero
} = require('./helpers/nuget-fixtures.js');

const t = new ServiceTester({ id: 'powershellgallery', title: 'PowerShell Gallery' });
module.exports = t;
Expand Down Expand Up @@ -47,6 +53,42 @@ t.create('version (valid)')
value: isVPlusDottedVersionNClauses,
}));

t.create('version (mocked, yellow badge)')
.get('/v/ACMESharp.json?style=_shields_test')
.intercept(nock => nock('https://www.powershellgallery.com')
.get("/api/v2/Packages()?$filter=Id%20eq%20%27ACMESharp%27%20and%20IsLatestVersion%20eq%20true")
.reply(200, versionJsonWithDash)
)
.expectJSON({
name: 'powershellgallery',
value: 'v1.2-beta',
colorB: colorscheme.yellow.colorB
});

t.create('version (mocked, orange badge)')
.get('/v/ACMESharp.json?style=_shields_test')
.intercept(nock => nock('https://www.powershellgallery.com')
.get("/api/v2/Packages()?$filter=Id%20eq%20%27ACMESharp%27%20and%20IsLatestVersion%20eq%20true")
.reply(200, versionJsonFirstCharZero)
)
.expectJSON({
name: 'powershellgallery',
value: 'v0.35',
colorB: colorscheme.orange.colorB
});

t.create('version (mocked, blue badge)')
.get('/v/ACMESharp.json?style=_shields_test')
.intercept(nock => nock('https://www.powershellgallery.com')
.get("/api/v2/Packages()?$filter=Id%20eq%20%27ACMESharp%27%20and%20IsLatestVersion%20eq%20true")
.reply(200, versionJsonFirstCharNotZero)
)
.expectJSON({
name: 'powershellgallery',
value: 'v1.2.7',
colorB: colorscheme.blue.colorB
});

t.create('version (not found)')
.get('/v/not-a-real-package.json')
.expectJSON({name: 'powershellgallery', value: 'not found'});
Expand Down Expand Up @@ -74,6 +116,42 @@ t.create('version (pre) (valid)')
value: isVPlusDottedVersionNClauses,
}));

t.create('version (pre) (mocked, yellow badge)')
.get('/vpre/ACMESharp.json?style=_shields_test')
.intercept(nock => nock('https://www.powershellgallery.com')
.get("/api/v2/Packages()?$filter=Id%20eq%20%27ACMESharp%27%20and%20IsAbsoluteLatestVersion%20eq%20true")
.reply(200, versionJsonWithDash)
)
.expectJSON({
name: 'powershellgallery',
value: 'v1.2-beta',
colorB: colorscheme.yellow.colorB
});

t.create('version (pre) (mocked, orange badge)')
.get('/vpre/ACMESharp.json?style=_shields_test')
.intercept(nock => nock('https://www.powershellgallery.com')
.get("/api/v2/Packages()?$filter=Id%20eq%20%27ACMESharp%27%20and%20IsAbsoluteLatestVersion%20eq%20true")
.reply(200, versionJsonFirstCharZero)
)
.expectJSON({
name: 'powershellgallery',
value: 'v0.35',
colorB: colorscheme.orange.colorB
});

t.create('version (pre) (mocked, blue badge)')
.get('/vpre/ACMESharp.json?style=_shields_test')
.intercept(nock => nock('https://www.powershellgallery.com')
.get("/api/v2/Packages()?$filter=Id%20eq%20%27ACMESharp%27%20and%20IsAbsoluteLatestVersion%20eq%20true")
.reply(200, versionJsonFirstCharNotZero)
)
.expectJSON({
name: 'powershellgallery',
value: 'v1.2.7',
colorB: colorscheme.blue.colorB
});

t.create('version (pre) (not found)')
.get('/vpre/not-a-real-package.json')
.expectJSON({name: 'powershellgallery', value: 'not found'});
Expand Down

0 comments on commit fdd6af4

Please sign in to comment.