Skip to content

Commit

Permalink
📖 add Hindi localization (#22)
Browse files Browse the repository at this point in the history
* add Hindi localization

* 📖 hindi translation progress

* 📖 complete feature example localization
  • Loading branch information
depapp authored Oct 26, 2022
1 parent c63d4e1 commit 186442d
Show file tree
Hide file tree
Showing 7 changed files with 258 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async function promptForMissingOptions(options) {
type: 'list',
name: 'template',
message: 'what language/localisation do you want to use?',
choices: ['indonesian', 'english', 'korean'],
choices: ['indonesian', 'english', 'korean', 'hindi'],
default: defaultTemplate,
});
}
Expand Down
6 changes: 6 additions & 0 deletions templates/hindi/config/cucumber.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"default": {
"language": "hi",
"format": ["summary", "html:cucumber-report.html"]
}
}
97 changes: 97 additions & 0 deletions templates/hindi/features/example-authentication.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
रूप लेख: प्रमाणीकरण चालू ADEQUATESHOP API

प्रमाणीकरण उदाहरण के साथ एपीआई ऑटोमेशन

परिदृश्य: पंजीकृत डेटा का उपयोग कर उपयोगकर्ता पंजीकरण
अगर मैं एक बनाता हूँ "POST" का अनुरोध "http://restapi.adequateshop.com/api/authaccount/registration"
और मैंने शरीर को पर सेट किया है
"""
{
"name": "PactumJS 01",
"email": "[email protected]",
"password": 123456
}
"""
जब मुझे एक प्रतिक्रिया मिलती है
तब मुझे उम्मीद है कि प्रतिक्रिया की स्थिति होनी चाहिए "200"
और मुझे उम्मीद है कि प्रतिक्रिया में एक जेसन होना चाहिए
"""
{
"code": 1,
"message": "The email address you have entered is already registered",
"data": null
}
"""

परिदृश्य: अमान्य डेटा का उपयोग कर उपयोगकर्ता पंजीकरण
अगर मैं एक बनाता हूँ "POST" का अनुरोध "http://restapi.adequateshop.com/api/authaccount/registration"
और मैंने शरीर को पर सेट किया है
"""
{
"name": "PactumJS XXX",
"email": "pactumjsxxx",
"password": 123456
}
"""
जब मुझे एक प्रतिक्रिया मिलती है
तब मुझे उम्मीद है कि प्रतिक्रिया की स्थिति होनी चाहिए "400"
और मुझे उम्मीद है कि प्रतिक्रिया में एक जेसन होना चाहिए "ModelState"
"""
{
"User.email": [
"Enter valid email address"
]
}
"""

परिदृश्य: वैध डेटा का उपयोग करके उपयोगकर्ता लॉगिन
अगर मैं एक बनाता हूँ "POST" का अनुरोध "http://restapi.adequateshop.com/api/authaccount/login"
और मैंने शरीर को पर सेट किया है
"""
{
"email": "[email protected]",
"password": 123456
}
"""
जब मुझे एक प्रतिक्रिया मिलती है
तब मुझे उम्मीद है कि प्रतिक्रिया की स्थिति होनी चाहिए "200"
और मुझे उम्मीद है कि प्रतिक्रिया में एक जेसन स्कीमा होना चाहिए "data"
"""
{
"type": "object",
"properties": {
"Id": {
"type": "integer"
},
"Name": {
"type": "string"
},
"Email": {
"type": "string"
},
"Token": {
"type": "string"
}
}
}
"""

परिदृश्य: अमान्य डेटा का उपयोग करके उपयोगकर्ता लॉगिन
अगर मैं एक बनाता हूँ "POST" का अनुरोध "http://restapi.adequateshop.com/api/authaccount/login"
और मैंने शरीर को पर सेट किया है
"""
{
"email": "[email protected]",
"password": 111222333
}
"""
जब मुझे एक प्रतिक्रिया मिलती है
तब मुझे उम्मीद है कि प्रतिक्रिया की स्थिति होनी चाहिए "200"
और मुझे उम्मीद है कि प्रतिक्रिया में एक जेसन होना चाहिए
"""
{
"code": 1,
"message": "invalid username or password",
"data": null
}
"""
11 changes: 11 additions & 0 deletions templates/hindi/features/support/data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { faker } = require('@faker-js/faker')

const randomData = {
name: faker.name.fullName(),
email: faker.internet.email(),
password: faker.internet.password()
}

module.exports = {
randomData
}
6 changes: 6 additions & 0 deletions templates/hindi/features/support/defaults.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const { request, settings } = require('pactum')
const { Before } = require('@cucumber/cucumber')

Before(() => {
settings.setReporterAutoRun(false)
})
111 changes: 111 additions & 0 deletions templates/hindi/features/support/steps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
const pactum = require('pactum')
const { Given, When, Then, Before, After } = require('@cucumber/cucumber')
const { randomData } = require('./data')

let spec = pactum.spec()
let fakerData = {
"name": randomData.name,
"email": randomData.email,
"password": randomData.password
}

Before(() => {
spec = pactum.spec()
})

Given(/^ "(.*)" "(.*)"$/, function (method, endpoint) {
spec[method.toLowerCase()](endpoint)
})

Given(/^I set path param "(.*)" to "(.*)"$/, function (key, value) {
spec.withPathParams(key, value)
})

Given(/^I set query param "(.*)" to "(.*)"$/, function (key, value) {
spec.withQueryParams(key, value)
})

Given(/^I set basic authentication credentials "(.*)" and "(.*)"$/, function (username, password) {
spec.withAuth(username, password)
})

Given(/^I set header "(.*)" to "(.*)"$/, function (key, value) {
spec.withHeaders(key, value)
})

Given(/ ि /, function (body) {
try {
spec.withJson(JSON.parse(body))
} catch(error) {
spec.withBody(body)
}
})

Given('मैं खाता बनाने के लिए यादृच्छिक परीक्षण डेटा का उपयोग करता हूं', function () {
console.log(fakerData)
spec.withJson(fakerData)
})

Given(/^ "(.*)"$/, function (filePath) {
spec.withFile(filePath)
})

Given(/^ - ि "(.*)" to "(.*)"$/, function (key, value) {
spec.withMultiPartFormData(key, value)
})

When('मुझे एक प्रतिक्रिया मिलती है', async function () {
await spec.toss()
})

Then('मुझे उम्मीद है कि प्रतिक्रिया की स्थिति होनी चाहिए "{int}"', function (code) {
spec.response().should.have.status(code)
})

Then(/^I expect response header "(.*)" should be "(.*)"$/, function (key, value) {
spec.response().should.have.header(key, value)
})

Then(/^I expect response header "(.*)" should have "(.*)"$/, function (key, value) {
spec.response().should.have.headerContains(key, value)
})

Then(/^ ि िि ि$/, function (json) {
spec.response().should.have.json(JSON.parse(json))
})

Then(/^ ि िि ि "(.*)"$/, function (path, value) {
spec.response().should.have.json(path, JSON.parse(value))
})

Then(/^I expect response should have a json like$/, function (json) {
spec.response().should.have.jsonLike(JSON.parse(json))
})

Then(/^I expect response should have a json like at "(.*)"$/, function (path, value) {
spec.response().should.have.jsonLike(path, JSON.parse(value))
})

Then(/^I expect response should have a json schema$/, function (json) {
spec.response().should.have.jsonSchema(JSON.parse(json))
})

Then(/^ ि िि ि "(.*)"$/, function (path, value) {
spec.response().should.have.jsonSchema(path, JSON.parse(value))
})

Then(/^I expect response should have a body$/, function (body) {
spec.response().should.have.body(body)
})

Then('मुझे उम्मीद है कि प्रतिक्रिया होनी चाहिए "{string}"', function (handler) {
spec.response().should.have._(handler)
})

Then(/^I store response at "(.*)" as "(.*)"$/, function (path, name) {
spec.stores(name, path)
})

After(() => {
spec.end()
})
26 changes: 26 additions & 0 deletions templates/hindi/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "pusakatest",
"version": "2.0.1",
"description": "pusakatest is an automation testing tool based on pactum using bdd (cucumber) style",
"main": "index.js",
"scripts": {
"test": "cucumber-js --config config/cucumber.json",
"test-publish": "cucumber-js --config config/cucumber.json --publish"
},
"repository": {
"type": "git",
"url": "git+https://github.com/depapp/pusakatest.git"
},
"author": "@depapp",
"license": "ISC",
"bugs": {
"url": "https://github.com/depapp/pusakatest/issues"
},
"homepage": "https://github.com/depapp/pusakatest#readme",
"devDependencies": {
"@cucumber/cucumber": "latest",
"@faker-js/faker": "latest",
"mocha": "latest",
"pactum": "latest"
}
}

0 comments on commit 186442d

Please sign in to comment.