mirror of
https://github.com/sasjs/adapter.git
synced 2025-12-11 09:24:35 +00:00
fix: removed shortening
This commit is contained in:
@@ -5,10 +5,6 @@ export const extractUserNameSas9 = (response: string) => {
|
||||
const username = matched?.[0].slice(17, -1)
|
||||
|
||||
if (!username) return 'unknown (error fetching username)'
|
||||
if (!username.trim().includes(' ')) return username.trim()
|
||||
|
||||
return username
|
||||
.split(' ')
|
||||
.map((name: string) => name.slice(0, 3).toLowerCase())
|
||||
.join('')
|
||||
return username.trim()
|
||||
}
|
||||
|
||||
@@ -5,14 +5,14 @@ describe('Extract username SAS9', () => {
|
||||
const response = ` "title": "Log Off SAS User One",`
|
||||
const username = extractUserNameSas9(response)
|
||||
|
||||
expect(username).toEqual('sasuseone')
|
||||
expect(username).toEqual('SAS User One')
|
||||
})
|
||||
|
||||
it('should return username with fallback regex', () => {
|
||||
const response = ` "title": "Logout SAS User One",`
|
||||
const username = extractUserNameSas9(response)
|
||||
|
||||
expect(username).toEqual('sasuseone')
|
||||
expect(username).toEqual('SAS User One')
|
||||
})
|
||||
|
||||
it('should return username unknown', () => {
|
||||
@@ -22,20 +22,13 @@ describe('Extract username SAS9', () => {
|
||||
expect(username).toEqual('unknown (error fetching username)')
|
||||
})
|
||||
|
||||
it('should return username without shortening (one word user name)', () => {
|
||||
it('should return username with one word user name', () => {
|
||||
const response = ` "title": "Log Off SasUserOne",`
|
||||
const username = extractUserNameSas9(response)
|
||||
|
||||
expect(username).toEqual('SasUserOne')
|
||||
})
|
||||
|
||||
it('should return username with falback regex without shortening (one word user name)', () => {
|
||||
const response = ` "title": "Logout SasUserOne",`
|
||||
const username = extractUserNameSas9(response)
|
||||
|
||||
expect(username).toEqual('SasUserOne')
|
||||
})
|
||||
|
||||
it('should return username with unhandled Spanish language', () => {
|
||||
const response = ` "title": "Desconectarse SAS User One",`
|
||||
const username = extractUserNameSas9(response)
|
||||
@@ -43,6 +36,6 @@ describe('Extract username SAS9', () => {
|
||||
// Result won't be perfect but it will work Result will be: ctasasuseone
|
||||
// instead of sasuseone
|
||||
|
||||
expect(username).toEqual('ctasasuseone')
|
||||
expect(username).toEqual('ctarse SAS User One')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user