Skip to content

Commit

Permalink
fix: make skeleton tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Wikström committed Aug 15, 2022
1 parent 0f76362 commit aa8b3d5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 47 deletions.
29 changes: 0 additions & 29 deletions test/common.test.spec.js

This file was deleted.

23 changes: 6 additions & 17 deletions test/consumers.test.spec.js
@@ -1,7 +1,7 @@
import { render } from '@asyncapi/generator-react-sdk';
import AsyncAPIDocument from '@asyncapi/parser/lib/models/asyncapi';
import { Consumers } from '../components/Consumers';
import { cleanString } from '../utils/common';
import { cleanString, getChannels } from '../utils/common';

describe('Consumers component', () => {
it('should render consumer implementation', () => {
Expand Down Expand Up @@ -48,24 +48,13 @@ describe('Consumers component', () => {
},
});

const expected = `// Handler for 'Subscribe to a temperature change from a specific sensor.'
_channel.QueueDeclare(\"temperatures\");
_channel.QueueBind(queue: \"temperatures\",
exchange: \"temperature\",
routingKey: \"{sensorId}.temperature\");
var onSpecificSensorTemperatureReceived = new EventingBasicConsumer(_channel);
onSpecificSensorTemperatureReceived.Received += (model, ea) =>
const expected = `protected override Task ExecuteAsync(CancellationToken stoppingToken)
{
var body = ea.Body.ToArray();
var message = JsonSerializer.Deserialize<Temperature>(Encoding.UTF8.GetString(body));
_logger.Verbose(\"Temperature received, {@Temperature}\", message);
// TODO - handle message
};
_channel.BasicConsume(queue: \"temperatures\",
autoAck: true,
consumer: onSpecificSensorTemperatureReceived);`;
_amqpService.OnSpecificSensorTemperatureReceived();
return Task.CompletedTask;
}`;

const result = render(<Consumers channels={asyncapi.channels()} />);
const result = render(<Consumers channels={getChannels(asyncapi)} />);

expect(cleanString(result)).toEqual(cleanString(expected));
});
Expand Down
2 changes: 1 addition & 1 deletion test/producers.test.spec.js
@@ -1,5 +1,5 @@
describe('Producer component tests', () => {
it('should render producer implementation', () => {
expect(true).toEqual(true);
expect(true).toEqual(true); // TODO: test implementation
});
});

0 comments on commit aa8b3d5

Please sign in to comment.