Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
johncmckim committed Jul 6, 2017
1 parent 1ba1c70 commit 75aaacf
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 54 deletions.
14 changes: 7 additions & 7 deletions .travis.yml
@@ -1,17 +1,17 @@
language: node_js
node_js:
- '4.4'
- '5.11'
- '6.2'
- '4.4'
- '5.11'
- '6.2'

before_install:
- npm install -g yarn
- npm install -g yarn
install:
- yarn
- yarn

script:
- yarn run lint
- yarn run test -- --coverage
- yarn run lint
- yarn run test

after_success:
- cat ./coverage/lcov.info | ./node_modules/.bin/coveralls && rm -rf ./coverage
Expand Down
5 changes: 2 additions & 3 deletions package.json
Expand Up @@ -6,9 +6,8 @@
"scripts": {
"lint": "eslint .",
"lint-fix": "eslint . --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cover": "jest --coverage"
"test": "jest --coverage",
"test:watch": "jest --watch"
},
"repository": {
"url": "https://github.com/ACloudGuru/serverless-plugin-aws-alerts.git",
Expand Down
52 changes: 8 additions & 44 deletions src/index.test.js
Expand Up @@ -154,7 +154,7 @@ describe('#index', function () {
definitions: {
functionErrors: {
metric: 'Errors',
threshold: 10,
threshold: 1,
statistic: 'Maximum',
period: 300,
evaluationPeriods: 1,
Expand Down Expand Up @@ -188,7 +188,7 @@ describe('#index', function () {
functionErrors: {
namespace: 'AWS/Lambda',
metric: 'Errors',
threshold: 10,
threshold: 1,
statistic: 'Maximum',
period: 300,
evaluationPeriods: 1,
Expand All @@ -206,7 +206,7 @@ describe('#index', function () {
functionThrottles: {
namespace: 'AWS/Lambda',
metric: 'Throttles',
threshold: 50,
threshold: 1,
statistic: 'Sum',
period: 60,
evaluationPeriods: 1,
Expand Down Expand Up @@ -244,40 +244,22 @@ describe('#index', function () {
]
};

it('should get default function alarms - no alarms', () => {
it('should get no alarms', () => {
const plugin = pluginFactory(config);
const definitions = plugin.getDefinitions(config);
const actual = plugin.getFunctionAlarms({}, config, definitions);

expect(actual).toEqual([{
name: 'functionInvocations',
namespace: 'AWS/Lambda',
metric: 'Invocations',
threshold: 100,
statistic: 'Sum',
period: 60,
evaluationPeriods: 1,
comparisonOperator: 'GreaterThanThreshold',
}]);
expect(actual).toEqual([]);
});

it('should get default function alarms - empty alarms', () => {
it('should get empty alarms', () => {
const plugin = pluginFactory(config);
const definitions = plugin.getDefinitions(config);
const actual = plugin.getFunctionAlarms({
alarms: []
}, config, definitions);

expect(actual).toEqual([{
name: 'functionInvocations',
namespace: 'AWS/Lambda',
metric: 'Invocations',
threshold: 100,
statistic: 'Sum',
period: 60,
evaluationPeriods: 1,
comparisonOperator: 'GreaterThanThreshold',
}]);
expect(actual).toEqual([]);
});

it('should get defined function alarms', () => {
Expand All @@ -290,15 +272,6 @@ describe('#index', function () {
}, config, definitions);

expect(actual).toEqual([{
name: 'functionInvocations',
namespace: 'AWS/Lambda',
metric: 'Invocations',
threshold: 100,
statistic: 'Sum',
period: 60,
evaluationPeriods: 1,
comparisonOperator: 'GreaterThanThreshold',
}, {
name: 'customAlarm',
namespace: 'AWS/Lambda',
metric: 'Invocations',
Expand Down Expand Up @@ -327,15 +300,6 @@ describe('#index', function () {
}, config, definitions);

expect(actual).toEqual([{
name: 'functionInvocations',
namespace: 'AWS/Lambda',
metric: 'Invocations',
threshold: 100,
statistic: 'Sum',
period: 60,
evaluationPeriods: 1,
comparisonOperator: 'GreaterThanThreshold',
}, {
name: 'fooAlarm',
namespace: 'AWS/Lambda',
metric: 'Invocations',
Expand Down Expand Up @@ -661,7 +625,7 @@ describe('#index', function () {
const definition = {
namespace: 'AWS/Lambda',
metric: 'Errors',
threshold: 10,
threshold: 1,
statistic: 'Maximum',
period: 300,
evaluationPeriods: 1,
Expand Down

0 comments on commit 75aaacf

Please sign in to comment.